ROOT_DIR=~/llvm-16.0.6
# ROOT_DIR=~/disk2/llvm-16.0.6-shared

LLVM_CONFIG=${ROOT_DIR}/bin/bin/llvm-config
CXX=${ROOT_DIR}/bin/bin/clang++

# LLVM_CONFIG=llvm-config
# CXX=clang++

CXXFLAGS+=$(shell $(LLVM_CONFIG) --cxxflags) -fno-rtti
CPPFLAGS+=$(shell $(LLVM_CONFIG) --cppflags) -g
LDFLAGS+=$(shell $(LLVM_CONFIG) --ldflags) -shared

SRC=$(wildcard *.cpp)
OBJ=$(patsubst %.cpp, %.so, $(SRC))

.PHONY:all clean
all: $(OBJ)

%.so: %.cpp
	@echo Compiling $*.cpp
	$(CXX) $< $(CPPFLAGS) $(CXXFLAGS) -o $@ $(LDFLAGS) `$(LLVM_CONFIG) --libs --system-libs`

clean:
	rm -rf $(OBJ)
